package com.atguigu.bigdata.test

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @Author: yqb
 * @Date: 2022/6/4 21:22 
 * @Description: Demon 
 * @Version: 1.0
 * */
object Need01 {
    def main(args: Array[String]): Unit = {

        /**
         * 小功能：从服务器日志数据 apache.log 中获取用户请求 URL 资源路径
         * map 操作
         *
         */

        val need01: SparkConf = new SparkConf().setMaster("local[*]").setAppName("Need01")
        val context = new SparkContext(need01)

        //1. 读文件
        val value: RDD[String] = context.textFile("datas/apache.log")

        //2. line ---> url
        val value1: RDD[String] = value.map(
            line => {
                val strings: Array[String] = line.split(" ")

                strings(6)
            }
        )

        value1.collect().foreach(println)
        // did


        context.stop()


    }

}
